#ifndef NETWORKPROPERTYDIALOG_H
#define NETWORKPROPERTYDIALOG_H

#include <QDialog>
#include <QListWidget>
#include <QPushButton>
#include <QLabel>
#include <QCheckBox>
#include "networkinfo.h"

class NetworkPropertyDialog : public QDialog {
    Q_OBJECT
public:
    NetworkPropertyDialog(const ConnectionInfo &connInfo, const DeviceInfo &devInfo, QWidget *parent = nullptr);
    ~NetworkPropertyDialog();
private slots:
    void onProtocolSelectionChanged();
    void onProtocolToggled(QListWidgetItem *item);
    void onPropertyClicked();
    void onOkClicked();
    void onCancelClicked();
private:
    void loadProtocolStates();
    void saveProtocolStates();
    void updateDescription();
    void applyIPv4Settings();
    ConnectionInfo m_connInfo;
    DeviceInfo m_devInfo;
    QListWidget *protocolList;
    QPushButton *btnInstall;
    QPushButton *btnUninstall;
    QPushButton *btnProperty;
    QLabel *descLabel;
    QPushButton *btnOk;
    QPushButton *btnCancel;
    QMap<QString, QListWidgetItem*> protocolItems;
    
    // IPv4设置缓存
    struct IPv4Settings {
        bool autoIP;
        QString ip;
        QString mask;
        QString gateway;
        bool autoDNS;
        QString dns1;
        QString dns2;
        bool autoConnect;
        bool hasChanges;
        int dnsPriority;
        // 多IP支持
        QList<QPair<QString, QString>> ipList;
        // 多网关支持
        QList<QPair<QString, int>> gatewayList; // 网关, metric
    };
    IPv4Settings m_ipv4Settings;
};

#endif // NETWORKPROPERTYDIALOG_H 